<?php

class Empeval_Methods_Request_SetEmpevalResult {
	
	/**
	 *
	 * @var App_Methods_Data_App
	 */
	public $app;
	public $bonusGoalsFormId;
	public $evaluationId;
	public $userId;
	
	public function __construct($params) {
		$this->app = new App_Methods_Data_App($params->app);
		$this->bonusGoalsFormId = $params->bonusGoalsFormId;
		$this->evaluationId = $params->evaluationId;
		$this->userId = $params->userId;
	}
	
	public function process() {
		$evaluation = EmpevalEmployeeEvaluationsQuery::create()
		->filterByUserId($this->userId)
		->filterByBonusGoalsFormId($this->bonusGoalsFormId)
		->findOne();
		
		if (!($evaluation instanceof EmpevalEmployeeEvaluations))
			throw new Empeval_Exception_App(Empeval_Exception_Codes::INFO_ACCESS_DENIED);
		
		$evaluation->setEvaluationId($this->evaluationId);
		$evaluation->save();
		
		return new Empeval_Methods_Response_SetEmpevalResult(true);
	}
	
}